<template>
	<view class="">
			<view class="flex-start-center  "  style="padding: 0 15rpx;margin: 20rpx 0;">
				<view :class="[currentIndex==index?'allActive flex':'all flex']" v-for="(item,index) in tabsList" :key="index" @click="switchTabsFn(index,item.id) ">
					{{item.name}}
				</view>
			
			</view>
		
		<mescroll-body ref="mescrollRef" :height="windowHeight+'rpx'" @init="mescrollInit" @down="downCallback"
			@up="upCallback" :up="upOption" :down="downOption">
			<block v-for="(item, j) in list" :key="j">

				<view class="verificationCard ">
					<view style="color:rgb(153, 153, 153);font-size: 32rpx;font-weight: 600; margin: 18rpx 0;" >
						<text>订单号：{{item.order_sn}}</text>
					</view>

					<view class="">

						<view style="color:  #A265FC;font-size: 32rpx;font-weight: 600;margin-top: 15rpx;">
							<text>购买会员名：{{item.name}}</text>
						</view>
						<view style="color:   #A265FC;font-size: 32rpx;font-weight: 600;margin-top: 15rpx;">
							<text>
								购买价格：{{item.price}}
							</text>
						</view>

						<view style="color: #A265FC;;margin-top: 15rpx;font-weight: 600">
							<text>有效期：{{item.effective_time}}天</text>
						</view>
						<view style="color:rgb(153, 153, 153);margin-top: 15rpx;">
							<text>生成时间：{{item.create_time}}</text>
						</view>
					</view>


				</view>


			</block>
		</mescroll-body>
	</view>
</template>

<script>
	export default {
		components: {

		},
		data() {
			return {
				tabIndex: 4,
				windowHeight: '',
				downOption: {
					auto: true
				},
				tabsList:[{
					name:'购买记录',
					id:'1'
				},{
					name:'卡密记录',
					id:'2'
				}],
				// 上拉配置项
				upOption: {
					auto: true
				},
				userInfo: uni.getStorageSync("userInfo"),
				// 套餐卡列表（已经购买）
				verificationList: [],
				list: [],
				id: '',
				currentIndex:0,
				type:1
			}
		},
		onLoad(options) {
			if (options.id) {
				this.id = options.id

			}
			console.log('page Show')
			uni.getSystemInfo({
				success: (res) => {
					this.windowHeight = res.windowHeight * 2 - 800;
				}
			});

		},
		onShow() {
			this.$nextTick(() => {
				this.mescroll?.resetUpScroll();
			})
		},
		methods: {
			switchTabsFn(index,type){
				this.type=type
				this.currentIndex=index
				
				this.$nextTick(() => {
					this.mescroll?.resetUpScroll();
				})
			},
			async upCallback(scroll) {

				const result = await this.$http.post({
					url: this.$api.userLevelOrderList,
					data: {
						page: scroll.num,
						limit: 10,
						status: 2,
                        type:this.type,
						is_oneself_uid: this.userInfo.id,


					},
					headers: {
						'Authorization': this.userInfo.token
					}

				})


				if (result.code == 0) {
					console.log('地址管理列表', result);
					this.mescroll.endByPage(result.data.list.length, this.$sun.pagingSum(result.data.count, 10));
					if (scroll.num == 1) this.list = [];
					this.list = this.list.concat(result.data.list);
					console.log('this.list', this.list, this.list.length);
				}
			},
		}
	}
</script>

<style>
	page {
		background: #f6f6f6;
		padding: 26rpx;
	}

	.verificationCard {
		border-radius: 20rpx;
		margin-top: 20rpx;
		background: rgb(255, 255, 255);
		padding: 26rpx;
	}
	.allActive {
		padding: 15rpx;
		height: 46rpx;
		border-radius: 10rpx;
		color: rgb(255, 255, 255);
		background:#1E6CEB;
		margin-right: 20rpx;
	}
	
	.all {
		margin-right : 20rpx;
		padding: 15rpx;
		height: 46rpx;
		border-radius: 10rpx;
		color: #A1A1A1;
		background:#ECECEC;
	}
</style>